package client

import (
	"image/color"
	"log"
	"strconv"
)

func HEXToColorNRGBA(HEX string) color.NRGBA {
	color64, err := strconv.ParseInt(HEX, 16, 32) //字串到数据整型
	if err != nil {
		log.Println("color err")
	}
	color32 := int(color64) //类型强转
	r, g, b := ColorToRGB(color32)
	return color.NRGBA{uint8(r), uint8(g), uint8(b), 255}
}

func ColorToRGB(color int) (red, green, blue int) {
	red = color >> 16
	green = (color & 0x00FF00) >> 8
	blue = color & 0x0000FF
	return
}
